﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using MySql.Data.MySqlClient;
using MySqlDBhelper;
namespace 高频打印
{
    public partial class FormSelect : Form
    {

        //MySqlConnection conn = new MySqlConnection("data source=localhost;database=test;user id=root;password=root;pooling=false;charset=utf8");
        MySqlConnection conn = new MySqlConnection(DbHelperMySQL.connectionString);

        public FormSelect()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormLogin FormMain = new FormLogin(); //自己改成登录框名称
            FormMain.ShowDialog();
            this.Close();
        }

        private void FormSelect_Load(object sender, EventArgs e)
        {
            button1.Enabled = false;
            string[] sArray = Regex.Split(Class1.storeIDGroup, ",", RegexOptions.IgnoreCase);
            foreach (string i in sArray)
            {
                comboBox1.Items.Add(i);
            }

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {


            }
            else
            {
               
                string sql = "select * from Depart_Table where DepartID='" + comboBox1.Text + "'";
                DataTable dtShow = new DataTable();
                MySqlDataAdapter sda = new MySqlDataAdapter(sql, conn);
                sda.Fill(dtShow);
                if (dtShow.Rows.Count > 0)
                {
                    textBox1.Text = dtShow.Rows[0][1].ToString();
                    textBox2.Text = dtShow.Rows[0][2].ToString();
                }
                else
                {
                    MessageBox.Show("在门店表里面，没有该门店ID数据，请联系管理员进行维护");
                    button1.Enabled = false;
                    return;
                }
                Class1.storeID = comboBox1.Text;
                button1.Enabled =true;

            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
           // FormSinglePrint FormMain = new FormSinglePrint(); //自己改成登录框名称
            //FormMain.ShowDialog();
            FormInput fi = new FormInput();
            fi.ShowDialog();
            this.Close();
        }
    }
}
